package com.kmh.musicplay.util;

import com.kmh.musicplay.data.ChannelData;
import com.kmh.musicplay.data.CommentData;
import com.kmh.musicplay.data.EventData;
import com.kmh.musicplay.data.FavoriteChannelData;
import com.kmh.musicplay.data.FavoriteVodData;
import com.kmh.musicplay.data.PortalData;
import com.kmh.musicplay.data.ProgramData;
import com.kmh.musicplay.data.SettingData;

/**
 * @author   user
 */
public class DataManager
{
	private static DataManager instance;
	private SettingData settingData;
	private PortalData portalData = new PortalData();
	private ChannelData channelData;
	private FavoriteChannelData favoriteChannelData;
	private FavoriteVodData favoriteVodData;
	private CommentData commentData;
	private ProgramData programData;
	private EventData eventData;
	
	public DataManager()
	{
		instance = this;
	}
	
	public static DataManager getInstance()
	{
		if(instance == null) new DataManager();
			return instance;
	}
	
	public SettingData getSettingData()
	{
		return settingData;
	}

	public void setSettingData(SettingData settingData)
	{
		this.settingData = settingData;
	}
	
	public CommentData getCommentData()
	{
		return commentData;
	}

	public void setCommentData(CommentData commentData)
	{
		this.commentData = commentData;
	}
	
	public FavoriteChannelData getFavoriteChannelData()
	{
		return favoriteChannelData;
	}

	public void setFavoriteChannelData(FavoriteChannelData favoriteChannelData)
	{
		this.favoriteChannelData = favoriteChannelData;
	}

	public FavoriteVodData getFavoriteVodData()
	{
		return favoriteVodData;
	}

	public void setFavoriteVodData(FavoriteVodData favoriteVodData)
	{
		this.favoriteVodData = favoriteVodData;
	}

	public PortalData getPortalData()
	{
		return portalData;
	}

	public void setPortalData(PortalData portalData)
	{
		this.portalData = portalData;
	}
	
	public ChannelData getChannelData()
	{
		return channelData;
	}

	public void setChannelData(ChannelData channelData)
	{
		this.channelData = channelData;
	}
	
	public ProgramData getProgramData()
	{
		return programData;
	}

	public void setProgramData(ProgramData programData)
	{
		this.programData = programData;
	}
	
	public EventData getEventData()
	{
		return eventData;
	}

	public void setEventData(EventData eventData)
	{
		this.eventData = eventData;
	}
	
	public void dispose()
	{
		
		if(portalData != null)
		{
			portalData.dispose();
			portalData = null;
		}
		
		if(favoriteChannelData != null)
		{
			favoriteChannelData.dispose();
			favoriteChannelData = null;
		}
		
		if(favoriteVodData != null)
		{
			favoriteVodData.dispose();
			favoriteVodData = null;
		}
		
		if(programData != null)
		{
			programData.dispose(false);
			programData = null;
		}
		
		if(eventData != null)
		{
			eventData.dispose(false);
			eventData = null;
		}
		instance = null;
	}
}
